/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pictionary2;

import java.awt.Point;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;

/**
 *
 * @author Viper
 */
public class EscuchadorEvento extends MouseMotionAdapter implements ActionListener{
       int num;
       private Socket s;
       BufferedReader br;
       private MSN msn;

       public EscuchadorEvento() throws UnknownHostException, IOException{
         }

       public void actionPerformed(ActionEvent e) {
        JButton btn = (JButton)e.getSource();
        String comando = btn.getActionCommand();
        try{
            if(comando.equals("enviar")){
                msn.getContactoActual().getOtroMensaje().append("\nYo >>"+msn.getContactoActual().getMiMensaje().getText());
                new Thread(new Escritor( getS(), getMsn(),0)).start();
            }
        } catch(Exception ex){
            System.out.println(ex.getMessage());
        }
        }

       public void mouseDragged( MouseEvent event ){
        /*   System.out.println("Entra al mouse");
           int pointCount=msn.getPaint().getPointCount();
           Point []points=msn.getPaint().getPoints();
               if ( pointCount < points.length ){
                  points[ pointCount ] = event.getPoint();
                  pointCount++;
                  msn.getPaint().repaint();
            try {
                new Escritor(s, msn).escribe(0);
            } catch (Exception ex) {
                System.out.println(ex.getMessage());
            }
               }*/
            }

    public MSN getMsn() {
        return msn;
    }

    public void setMsn(MSN msn) {
        this.msn = msn;
    }

    public Socket getS() {
        return s;
    }

    public void setS(Socket s) {
        this.s = s;
    }
}
